package com.mogu_soup.map;

import com.mogu_soup.entity.Bomb;
import com.mogu_soup.entity.Bullet;
import com.mogu_soup.entity.Entity;
import com.mogu_soup.entity.Tank;
import com.mogu_soup.util.BombPool;
import com.mogu_soup.util.MyUtil;

import java.awt.*;
import java.util.Vector;

/**
 * Version: 2.1
 * Author: TangJun
 * Date: 2024-08-03
 * Note:
 */
public class Brick extends Entity {
    private static final Image[] MAP_BRICK = new Image[]{
            MyUtil.createImage("resource\\map\\brick.gif"),
            MyUtil.createImage("resource\\map\\grass.png"),
            MyUtil.createImage("resource\\map\\steel.gif"),
            MyUtil.createImage("resource\\map\\water.gif"),
    };
    //砖块默认属性
    public static final int IMAGE_BRICK = 0;
    public static final int IMAGE_GRASS = 1;
    public static final int IMAGE_STEEL = 2;
    public static final int IMAGE_WATER = 3;


    public static final int DEFAULT_SIZE = Tank.DEFAULT_SIZE / 2;
    private static final int DEFAULT_HP = 2;


    private int type;//砖块类型

    //构造方法
    public Brick(int x, int y, int type) {
        this.x = x;
        this.y = y;
        this.type = type;
        hp = DEFAULT_HP;
        size = DEFAULT_SIZE;
        isLive = true;
    }


    //设置参数
    public void set(int x, int y, int type) {
        this.x = x;
        this.y = y;
        this.type = type;
        hp = DEFAULT_HP;
        size = DEFAULT_SIZE;
        isLive = true;
    }

    public int hpDown() {
        if (type != IMAGE_BRICK) {
            return hp;
        }
        return --hp;
    }

    //绘制砖块
    @Override
    public void draw(Graphics g) {
        g.drawImage(MAP_BRICK[type], x - size / 2, y - size / 2, size, size, null);
    }

    public int getType() {
        return type;
    }
}
